package com.moerlong.platform.service.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.moerlong.platform.service.remote.NetDemoClient;
import com.moerlong.platform.service.utils.R;

//开启restful api 返回json对象
@RestController
public class NetDemoController {
	//注入NetDemoClient对象  该对象定义了访问远程方法
    @Autowired NetDemoClient netClient;
    
    //http请求  -get  ip:端口/add？a=?&b=? 
    @RequestMapping(value = "/add",method = RequestMethod.GET)
    public R add(@RequestParam(value="a") int a, @RequestParam(value="b") int b){
        return netClient.add(a, b);
    }
    
    //http请求  -get  ip:端口/subtract？a=?&b=? 
    @RequestMapping(value = "/subtract",method = RequestMethod.GET)
    public R subtract(@RequestParam(value="a") int a, @RequestParam(value="b") int b){
        return netClient.subtract(a, b);
    }
}
